package com.alks.function.controller;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.WebLogger;
import com.alks.entity.data.entity.Quotation;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.data.request.quotation.*;
import com.alks.function.service.QuotationTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.util.List;

/**
 * @author:xxxxx
 * @create: 2023-06-16 17:58
 * @Description: 报价型体资料
 */
@Api(value = "荣阳总经办" ,tags = {"荣阳总经办--样品报价","荣阳查询--研发用量","荣阳总经办--取型体","荣阳查询--研发型体","总经办工厂-查询模块型体工艺","总经办工厂-型体bom查询"})
@Slf4j
@ApiRestController("/quotation")
public class QuotationTypeController {
    @Autowired
    QuotationTypeService quotationTypeService;

    @GetMapping("/quotationCondition")
    @WebLogger
    @ApiOperation(value = "报价型体条件返回" ,tags = {"荣阳总经办--样品报价"})
    public ResponseInfo quotationCondition(){
        return quotationTypeService.quotationCondition();
    }

    @PostMapping("/quotationList")
    @ApiOperation(value = "报价型体资料查询",tags = {"荣阳总经办--样品报价"})
    @WebLogger
    public ResponseInfo quotationList(@RequestBody QuotationTypeRequest request){
        return quotationTypeService.quotationList(request);
    }

    @PutMapping("/updateQuotationStyleCheck")
    @ApiOperation(value = "打勾型体检核/取消检核",tags = {"荣阳总经办--样品报价"})
    @WebLogger
    public ResponseInfo updateQuotationStyleCheck(@RequestBody QuotationTypeCheckRequest request){
        return quotationTypeService.updateQuotationStyleCheck(request);
    }

    @PostMapping("/quotationListDetail" )
    @ApiOperation(value = "报价型体明细资料查询",tags = {"荣阳总经办--样品报价"})
    @WebLogger
    public ResponseInfo quotationListDetail(@RequestBody QuotationTypeDetailRequest request){
        return quotationTypeService.quotationListDetail(request);
    }

    @ApiOperation(value = "修改报价型体参数",tags = {"荣阳总经办--样品报价"})
    @PutMapping("/updateQuotationTypeDetail")
    @WebLogger
    public ResponseInfo updateQuotationTypeDetail(@RequestBody IQuotationDetailRequest request){
        return quotationTypeService.updateQuotationTypeDetail(request);
    }

    @ApiOperation(value = "获取报价项目明细",tags = {"荣阳总经办--样品报价"})
    @GetMapping("/getYfStyleCostBase")
    @WebLogger
    public ResponseInfo getYfStyleCostBase(){
        return quotationTypeService.getYfStyleCostBase();
    }
//    @ApiOperation("设置报价项目明细")
//    @PostMapping("/setYfStyleCostBase")
//    public ResponseInfo setYfStyleCostBase(@RequestBody Map<String,Object> map){
//        return quotationTypeService.setYfStyleCostBase(map);
//    }
    @ApiOperation(value = "添加项目明细",tags = {"荣阳总经办--样品报价"})
    @PutMapping("/setQuotationTypeDetail")
    @WebLogger
    public ResponseInfo setQuotationTypeDetail(@RequestBody IQuotationDetailRequest request){
        return quotationTypeService.setQuotationTypeDetail(request);
    }

    @ApiOperation(value = "项目类型",tags = {"荣阳总经办--样品报价"})
    @GetMapping("/getMtlProperty")
    @WebLogger
    public ResponseInfo getMtlProperty(){
        return quotationTypeService.getMtlProperty();
    }

    @ApiOperation(value = "币别",tags = {"荣阳总经办--样品报价"})
    @GetMapping("/getCurrency")
    @WebLogger
    public ResponseInfo getCurrency(){
        return quotationTypeService.getCurrency();
    }

    @ApiOperation(value = "删除打勾材料明细",tags = {"荣阳总经办--样品报价"})
    @PostMapping("/deleteQuotationTypeDetail")
    @WebLogger
    public ResponseInfo deleteQuotationTypeDetail(@RequestBody DeleteQuotationDetailRequest request){
        return quotationTypeService.deleteQuotationTypeDetail(request);
    }

    @ApiOperation(value = "删除打勾型体",tags = {"荣阳总经办--样品报价"})
    @PostMapping("deleteQuotationType")
    @WebLogger
    public ResponseInfo deleteQuotationType(@RequestBody DeleteQuotationRequest request){
        return quotationTypeService.deleteQuotation(request);
    }


    @PutMapping("/updateUsdAndTypeName")
    @WebLogger
    @ApiOperation(value = "更新币别，项目类型",tags = "荣阳总经办--样品报价")
    public ResponseInfo updateUsdAndTypeName(@RequestBody UpdateQuotationRsbAndTypeRequest request){
        return quotationTypeService.updateUsdAndTypeName(request);
    }
    //修改币别


    @ApiOperation(value = "荣阳总经办--获取报价型体查询条件",tags = {"荣阳总经办--取型体"})
    @GetMapping("/getQuotationCondition")
    @WebLogger
    public ResponseInfo getQuotationCondition(){
        return  quotationTypeService.getQuotationCondition();
    }

    @ApiOperation(value = "荣阳总经办--取型体查询",tags = "荣阳总经办--取型体")
    @PostMapping("/getQuotation")
    @WebLogger
    public ResponseInfo getQuotation(@RequestBody GetQuotationRequest request){
        return  quotationTypeService.getQuotation(request);
    }

    @ApiOperation(value = "荣阳总经办--取型体",tags = "荣阳总经办--取型体")
    @PostMapping("/putQuotation")
    @WebLogger
    public  ResponseInfo quotationSetHeadAndDetail(@RequestBody QuotationRequest request){
        return quotationTypeService.quotationSetHeadAndDetail(request);
    }

    @ApiOperation(value = "荣阳总经办--取型体--勾选型体",tags = "荣阳总经办--取型体")
    @PostMapping("/gouXQuotation")
    @WebLogger
    public ResponseInfo gouXQuotation(@RequestBody Quotation quotation){
        return quotationTypeService.gouXQuotation(quotation);
    }
    //研发用量bom表导出
    @ApiOperation(value = "研发通量bom表导出",tags = "荣阳查询--研发用量")
    @PostMapping("/downloadReDevelop")
    @WebLogger
    public void downloadReDevelop(HttpServletResponse response,@RequestBody ReAndDevelopRequest req) throws MalformedURLException {
        quotationTypeService.downloadReDevelop(response,req);
    }

    @ApiOperation(value = "荣阳查询--研发用量查询",tags = "荣阳查询--研发用量")
    @PostMapping("/reAndDevelop")
    @WebLogger
    public ResponseInfo reAndDevelop(@RequestBody ReAndDevelopRequest request){
        return quotationTypeService.reAndDevelopList(request);
    }

    @ApiOperation(value = "荣阳查询--研发用量条件查询",tags = "荣阳查询--研发用量")
    @GetMapping("/getReAndDevelopCondition")
    @WebLogger
    public ResponseInfo getReAndDevelopCondition(){
        return quotationTypeService.getReAndDevelopCondition();
    }

    @ApiOperation(value = "研发用料材料查询",tags = "荣阳查询--研发用量")
    @PostMapping("/bomStyleMaterial")
    @WebLogger
    public ResponseInfo bomStyleMaterial(@RequestBody ReAndDevelopRequest request){
        return quotationTypeService.getBomStyleMaterial(request);
    }

    @ApiOperation(value = "荣阳查询--研发用量子材料明细查询",tags = "荣阳查询--研发用量")
    @GetMapping("/bomStyleDetail")
    @WebLogger
    public ResponseInfo bomStyleDetail(@RequestParam String mtlNo){
        return quotationTypeService.bomStyleDetail(mtlNo);
    }

    @ApiOperation(value = "设置荣阳查询--研发用量备注",tags = "荣阳查询--研发用量")
    @GetMapping("/setBomStyleRemark")
    @WebLogger
    public ResponseInfo setBomStyleRemark(@RequestParam String style,@RequestParam String color,@RequestParam(required = false) String remark){
        return quotationTypeService.setBomStyleRemark(style,color,remark);
    }

    @ApiOperation(value = "荣阳查询--研发型体查询条件返回",tags = "荣阳查询--研发型体")
    @GetMapping("/getStyleResearchCondition")
    @WebLogger
    public ResponseInfo getStyleResearchCondition(){
        return quotationTypeService.getStyleResearchCondition();
    }

    @ApiOperation(value = "荣阳查询--研发型体-型体查询",tags = "荣阳查询--研发型体")
    @PostMapping("/getStyleResearch")
    @WebLogger
    public ResponseInfo getStyleResearch(@RequestBody StyleResearchRequest request){
        return quotationTypeService.getStyleResearch(request);
    }

    @ApiOperation(value = "荣阳查询--研发型体-明细",tags = "荣阳查询--研发型体")
    @GetMapping("/getStyleResearchDetail")
    @WebLogger
    public ResponseInfo getStyleResearchDetail(@RequestParam String styleNo){
        return quotationTypeService.getStyleResearchDetail(styleNo);
    }

    //研发型体下载
    @PostMapping("/downloadStyle")
    @ApiOperation(value = "导出",tags = "荣阳查询--研发型体")
    @WebLogger
    public void downloadStyle(HttpServletResponse response,@RequestBody List<String> list) throws UnsupportedEncodingException {
        quotationTypeService.downloadStyle(response,list);
    }

    @ApiOperation(value = "型体工艺查询",tags = "总经办工厂-查询模块型体工艺")
    @PostMapping("/craft/getPcStyleCraftHead")
    @WebLogger
    public ResponseInfo getPcStyleCraftHead(@RequestBody PcStyleCraftRequest request){
        return quotationTypeService.getPcStyleCraftHead(request);
    }

    @ApiOperation(value = "型体生产工艺" ,tags = "总经办工厂-查询模块型体工艺")
    @GetMapping("/craft/getPcStyleCraftDetail")
    @WebLogger
    public ResponseInfo getPcStyleCraftDetail(@RequestParam String style, @RequestParam String color, @RequestParam(required = false) String flag){
        return quotationTypeService.getPcStyleCraftDetail(style,color,flag);
    }

    @ApiOperation(value = "型体配色材料查询",tags = "总经办工厂-型体bom查询")
    @PostMapping("/bomColor/getPcBomStyleColor")
    @WebLogger
    public ResponseInfo getPcBomStyleColor(@RequestBody PcBomColorRequest request){
        return quotationTypeService.getPcBomStyleColor(request);
    }

    @ApiOperation(value = "型体bom导出",tags = "总经办工厂-型体bom查询")
    @PostMapping("/bomColor/downloadPcBom")
    @WebLogger
    public void  downloadPcBom(HttpServletResponse response,@RequestBody PcBomColorRequest request) {
        quotationTypeService.downloadPcBom(response,request);
    }

    @ApiOperation(value = "型体配色材料查询贴合子材料明细",tags = "总经办工厂-型体bom查询")
    @GetMapping("/getPcBomStyleDetail")
    @WebLogger
    public ResponseInfo getPcBomStyleDetail(@RequestParam String mtlNo){
        return quotationTypeService.getPcBomStyleDetail(mtlNo);
    }
}
